package servlet;
import java.util.List;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Tools.Tools;
import bean.Users;
import biz.IUsersBiz;
import biz.impl.*;
@WebServlet("/GetUsersPage")
public class GetUsersPage extends HttpServlet {
		IUsersBiz biz=new UsersBiz();
		
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		int pageIndex=Integer.parseInt(request.getParameter("pageIndex"));
		int pageSize=Integer.parseInt(request.getParameter("pageSize")==null?"10":request.getParameter("pageSize"));
		List<Users> list=biz.getUsersPage(pageIndex, pageSize);
		request.setAttribute("list", list);
		request.setAttribute("pageIndex", pageIndex);
		request.setAttribute("pageSize", pageSize);
		request.setAttribute("count",biz.getUsersCount());
		request.setAttribute("pageMsg", Tools.paging(biz.getUsersCount(), pageSize, pageIndex, "GetUsersPage"));
		request.getRequestDispatcher("Manager.jsp").forward(request, response);
        
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
